using UnityEngine;
// [Assembly-CSharp.dll].Spider
public class Spider : MonoBehaviour
{
    // Fields
    public float target;
    public float speed;
    public bool move;
    private UnityEngine.Transform line;
    private UnityEngine.Vector2 diff;
    private UnityEngine.LineRenderer lineRen;
    private UnityEngine.Transform web;
    
    // Methods
    private void Update()
    {
        float val_37;
        float val_38;
        float val_39;
        float val_40;
        float val_41;
        float val_42;
        float val_43;
        UnityEngine.Vector3 val_1 = this.web.localPosition;
        this.lineRen.SetPosition(index:  0, position:  new UnityEngine.Vector3() {x = val_1.x, y = val_1.y, z = val_1.z});
        UnityEngine.Vector3 val_3 = this.transform.localPosition;
        this.lineRen.SetPosition(index:  1, position:  new UnityEngine.Vector3() {x = val_3.x, y = val_3.y, z = val_3.z});
        if(this.move == false)
        {
            goto label_5;
        }
        
        UnityEngine.Vector3 val_6 = this.transform.localPosition;
        val_37 = this.target;
        val_38 = this.speed;
        val_39 = val_6.y;
        float val_34 = UnityEngine.Time.deltaTime;
        val_40 = 0f;
        val_41 = val_37 - val_39;
        float val_8 = val_40 - val_6.x;
        float val_11 = (val_8 * val_8) + (val_41 * val_41);
        if(val_11 != 0f)
        {
                val_34 = val_38 * val_34;
            if(val_34 >= 0f)
        {
                if(val_11 <= (val_34 * val_34))
        {
            goto label_10;
        }
        
        }
        
            float val_13 = val_8 / val_40;
            val_40 = val_41 / val_40;
            val_13 = val_34 * val_13;
            val_40 = val_6.x + val_13;
            val_37 = val_39 + (val_34 * val_40);
        }
        
        label_10:
        val_42 = val_37;
        this.transform.localPosition = new UnityEngine.Vector3() {x = val_40, y = val_42, z = 0f};
        label_5:
        if(this.line == 0)
        {
                return;
        }
        
        UnityEngine.Vector3 val_18 = this.transform.transform.position;
        UnityEngine.Vector3 val_21 = this.transform.parent.position;
        if(val_18.y >= 0)
        {
            goto label_19;
        }
        
        UnityEngine.Vector3 val_22 = this.line.localPosition;
        float val_35 = val_22.x;
        UnityEngine.Vector3 val_23 = this.web.position;
        val_39 = val_23.x;
        val_43 = val_23.y;
        val_41 = UnityEngine.Time.deltaTime;
        val_38 = val_39 - val_35;
        float val_25 = val_43 - val_22.y;
        val_23.y = val_25 * val_25;
        val_35 = (val_38 * val_38) + val_23.y;
        if(val_35 == 0f)
        {
            goto label_25;
        }
        
        val_41 = this.speed * val_41;
        if(val_41 < 0f)
        {
            goto label_24;
        }
        
        float val_27 = val_41 * val_41;
        if(val_35 <= val_27)
        {
            goto label_25;
        }
        
        label_24:
        float val_28 = val_38 / val_27;
        val_27 = val_25 / val_27;
        val_28 = val_41 * val_28;
        val_27 = val_41 * val_27;
        val_39 = val_35 + val_28;
        val_43 = val_22.y + val_27;
        label_25:
        val_40 = val_39;
        val_42 = val_43;
        this.line.position = new UnityEngine.Vector3() {x = val_40, y = val_42, z = 0f};
        this.line.GetComponent<System.Object>().bodyType = 2;
        label_19:
        UnityEngine.Vector3 val_31 = this.web.position;
        UnityEngine.Vector3 val_33 = this.line.transform.position;
        val_33.y = val_33.y + val_33.x;
        this.transform.position = new UnityEngine.Vector3() {x = val_31.x, y = val_33.y, z = 0f};
    }
    private void OnTriggerEnter2D(UnityEngine.Collider2D collision)
    {
        var val_23 = this;
        if((collision.gameObject.CompareTag(tag:  -1610605719)) == false)
        {
                return;
        }
        
        this.transform.GetComponent<System.Object>().enabled = false;
        UnityEngine.Vector3 val_6 = this.transform.position;
        UnityEngine.Vector3 val_8 = collision.transform.position;
        val_8.x = val_6.x - val_8.x;
        val_8.y = val_6.y - val_8.y;
        this.diff = val_8.x;
        mem[1152921504930430452] = val_8.y;
        this.line = collision.transform;
        mem[1152921504930430432] = 0;
        this.line.GetComponent<System.Object>().mass = 1000f;
        val_23 = 27443960;
        collision.gameObject.GetComponent<System.Object>().gravityScale = 0f;
        collision.gameObject.GetComponent<System.Object>().freezeRotation = true;
        var val_23 = 0;
        do
        {
            if(val_23 >= (mem[536886749] + 24 + 32 + 24))
        {
                return;
        }
        
            mem[536886749] + 24 + 32.Item[0].GetChild(index:  UnityEngine.PlayerPrefs.GetInt(key:  -1610599417)).GetComponent<System.Object>().gravityScale = 0.5f;
            val_23 = mem[536886749] + 24 + 32.Item[0];
            val_23.GetChild(index:  UnityEngine.PlayerPrefs.GetInt(key:  -1610599417)).GetComponent<System.Object>().interpolation = 1;
            val_23 = val_23 + 1;
        }
        while(mem[536886749] != 0);
        
        throw new NullReferenceException();
    }
    public Spider()
    {
    
    }

}
